import Vue from 'vue'
import Router from 'vue-router'
import conversation from '../components/chat/conversation'
import friend from '../components/friend/friend'

Vue.use(Router)
let router = new Router({
  routes: [
    {
      path: '/',
      component: require('@/components/login').default
    }, {
      path: '/main',
      component: require('@/components/main').default,
      redirect: '/main/conversation',
      children: [
        {
          path: 'conversation',
          name: 'conversation',
          component: conversation
        }, {
          path: 'friend',
          name: 'friend',
          component: friend
        }
      ]
    }
  ]
})
// 全局前置路由守卫
router.beforeEach((to, from, next) => {
  console.log(to)
  console.log(from)
  next()
})
export default router
